<!--    系统配置 - 用户添加   jh -->
<template>
    <div>
        <div class="right">
            <div class="ca-box ca-p-10">
            <el-row >
                <el-col>
                    <div class="ca-title"><h3 class="h3">{{id==='-1'?'用户添加':'用户编辑'}}</h3></div>
                </el-col>
            </el-row>
            <div class="ca-m-t-20">
            <el-form ref="form" :model="form" :rules="rules" label-width="100px">
                <el-row >
                    <el-col :span="11">
                        <el-form-item label="电子邮箱：" prop="email">
                            <el-input v-model="form.email" placeholder="用于登录系统及接受初始密码"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="2" align="center">
                        <el-button type="primary" @click="restUserPassword()"  :disabled="id==='-1'">重置</el-button>
                    </el-col>
                    <el-col :span="11">
                        <el-form-item label="移动电话：" prop="telephone">
                            <el-input v-model="form.telephone" placeholder="邮箱太长可以用手机号登录"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="11">
                        <el-form-item label="用户名称："  prop="cnName" >
                            <el-input v-model="form.cnName" placeholder="选择输入用户名称" :maxlength="100"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="11" :offset="2">
                        <el-form-item label="英文名称：">
                            <el-input v-model="form.enName" placeholder="选择输入英文名称" :maxlength="100"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="11">
                        <el-form-item label="增加角色：">
                            <!--新建-->
                            <el-select  v-if="id==='-1'" class="coverWidth" v-model="currentRole" filterable placeholder="选择新增角色"
                                       @change="addToArr(currentRole,seclectRole,roleListAll)">
                                <el-option
                                    v-for="item in roleListAll"
                                    :label="item.name"
                                    :key="item.id"
                                    :value="item.id">
                                </el-option>
                            </el-select>
                            <!--编辑-->
                            <el-select  v-if="id!=='-1'" class="coverWidth" v-model="currentRole" filterable placeholder="选择新增角色"
                                       @change="addToArr(currentRole,seclectRole,roleListAll,true,callBack)">
                                <el-option
                                    v-for="item in roleListAll"
                                    :label="item.name"
                                    :key="item.id"
                                    :value="item.id">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="11" :offset="2">
                        <el-form-item label="部门：" prop="deptId">
                            <el-select  class="coverWidth" v-model="form.deptId"  placeholder="请选择部门">
                                <el-option
                                    v-for="item in departmentList"
                                    :label="item.deptName"
                                    :key="item.deptId"
                                    :value="item.deptId">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col class="authStyle">
                          <el-checkbox
                              :indeterminate="isIndeterminate"
                              v-model="checkAuthAll"
                              @change="handleCheckAllChange">
                              全数据权限
                          </el-checkbox>
                        <div style="margin: 15px 0;"></div>
                        <el-checkbox-group v-model="checkedAuth" @change="handleCheckedAuthChange">
                            <el-checkbox v-for="(item,index) in authAllList" :label="item" :key="item"></el-checkbox>
                        </el-checkbox-group>
                    </el-col>
                </el-row>
                <el-row class="tagStyle">
                    <el-col>
                        <el-form-item label="当前角色：">
                            <!--新建-->
                            <el-tag
                                v-if="id==='-1'"
                                class="tagStyle-tag"
                                @close="deleteConnectRole(tag,seclectRole)"
                                v-for="(tag, index ) in seclectRole"
                                :key="tag.id"
                                :type="tag.color"
                                closable>
                                {{tag.name}}
                            </el-tag>
                            <!--编辑时，删除tag标签时需要调借口,第三个参数为删除关联角色的函数-->
                            <el-tag
                                v-if="id!=='-1'"
                                class="tagStyle-tag"
                                v-for="(tag, index ) in seclectRole"
                                @close="deleteConnectRole(tag,seclectRole)"
                                :key="tag.id"
                                :type="tag.color"
                                @click.native="selectHandleClickRole(tag,index)"
                                closable>
                                {{tag.name}}
                            </el-tag>
                        </el-form-item>
                    </el-col>
                </el-row>
                <!--// 1拟投资项目,2已投资项目,3母基金,4拟设立基金,5已设立基金,6客户,7潜在项目-->
                <!--<el-tabs v-model="activeName" class="ca-tabs" type="border-card"  v-if="id!=='-1'" @tab-click="handleClick">-->
                    <!--<el-tab-pane label="拟投资项目" name="first">-->
                        <!--<csPreInvestmentProject-->
                            <!--:getDataAuth="getDataAuth"-->
                            <!--:id="id" :roleId="roleId"-->
                            <!--type="1"-->
                            <!--:preInvestmentProjectTabData="preInvestmentProjectTabData">-->
                        <!--</csPreInvestmentProject>-->
                    <!--</el-tab-pane>-->
                    <!--<el-tab-pane label="已投资项目" name="second">-->
                        <!--<csEstablishedProject :getDataAuth="getDataAuth" :id="id" :roleId="roleId" type="2" :establishedProjectTabData="establishedProjectTabData"></csEstablishedProject>-->
                    <!--</el-tab-pane>-->
                    <!--<el-tab-pane label="拟设立基金" name="third">-->
                        <!--<csPreEstablishingFunds :getDataAuth="getDataAuth" :id="id" :roleId="roleId" type="4" :preEstablishingFundsTabData="preEstablishingFundsTabData"></csPreEstablishingFunds>-->
                    <!--</el-tab-pane>-->
                    <!--<el-tab-pane label="已设立基金" name="fourth">-->
                        <!--<csEstablishedFunds :getDataAuth="getDataAuth" :id="id" :roleId="roleId" type="5" :establishedFundsTabData="establishedFundsTabData"></csEstablishedFunds>-->
                    <!--</el-tab-pane>-->
                    <!--<el-tab-pane label="客户" name="five">-->
                        <!--<csClient :id="id" :getDataAuth="getDataAuth" :roleId="roleId" type="6" :clientTabData="clientTabData"></csClient>-->
                    <!--</el-tab-pane>-->
                <!--</el-tabs>-->
                <el-tabs v-model="activeName" type="border-card" class="ca-tabs" v-if="id!=='-1' && seclectRole.length !== 0 && allTabData.length !== 0" @tab-click="handleClick">
                    <el-tab-pane
                        v-for="(item, index) in allTabData"
                        :key="index"
                        :label="item.name"
                        :name="item.type"
                    >
                        <csPreInvestmentProject
                            :getDataAuth="getDataAuth"
                            :id="id" :roleId="roleId"
                            :type="item.type"
                            :preInvestmentProjectTabData="item.powerList"
                            :placeholder="item.placeholder"
                            :header="item.header"
                            :header2="item.header2"
                            :title="item.title"
                            :industryListAll ="item.industryListAll"
                            >
                        </csPreInvestmentProject>
                    </el-tab-pane>
                </el-tabs>
                <el-row >
                    <el-col class="buttonStyle">
                        <el-button type="primary" @click="submitForm('form')">确定</el-button>
                        <el-button @click="cancel">取消</el-button>
                    </el-col>
                </el-row>
            </el-form>
            </div>
        </div>
      </div>
    </div>
</template>

<script type="text/ecmascript-6">
    import {api} from '__views/system-settings/user/api';
    import {STATUS_HTTP_SUCCESS, apiHttp} from '__service/csHttp';
    import mined from './mixin';
    import { arrayUnique } from '__service/utils';
    export default {
        mixins: [mined],
        data() {
            let validatePass = (rule, value, callback) => {
                if (value === '' || value === null) {
                    callback(new Error('请输入移动电话'));
                } else {
                    if (!(/^1(3|4|5|7|8)\d{9}$/.test(value))) {
                        callback(new Error('移动电话输入有误'));
                    } else {
                        callback();
                    }
                }
            };
            return {
                showTabArr: [],//当前数据的type数组
                roleId: '',//角色id 当前
                departmentList: this.$store.state.user.department.departmentList, //全部的部门
                id: this.$route.params.userId ,
                isEdit: false,
                activeName: '1', //面板切换
                roleListAll: this.$store.state.user.roles, //全部的角色
                currentRole: '',
                isIndeterminate: false, //indeterminate 属性用以表示 checkbox 的不确定状态，一般用于实现全选的效果
                checkAuthAll: false, //是否全选
                authAllList: ['拟投资项目全数据权限','已投资项目全数据权限','拟设立基金全数据权限','已设立基金全数据权限','客户全数据权限','项目库全数据权限','投资中母基金','基金储备全数据权限'],//权限列表（展示）
                checkedAuth: [], //选中的列表
                seclectRole: [], //选中的角色列表tag中的数据
                allTabData: [],//所有 权限数据
                clientTabData: [],//客户-- 权限数据
                preInvestmentProjectTabData: [],//拟投资项目-- 权限数据
                establishedProjectTabData: [],//已设立项目-- 权限数据
                preEstablishingFundsTabData: [],//拟设立基金-- 权限数据
                establishedFundsTabData: [],//已设立基金-- 权限数据
                industryListAll: this.$store.state.user.dictionaryMap.industry,//所有的行业
                guestRelationship: this.$store.state.user.dictionaryMap.guestType,//所有的客户关系
                flag: true,//阻止多次提交
                form: {
                   'id': '',//用户id
                   'ansatDataPower': 0, //拟设立基金全数据权限1为是0为否 ,=====
                   'cnName': '', //中文名 ,
                   'dataPower': 0,//项目基金数据权限 1为是0为否 ,=====
                   'deptId': '', //部门id
                   'email': '', //电子邮件
                   'enName': '',//英文名
                   'estDataPower': 0,//已设立基金全数据权限1为是0为否 ,====
                   'fofDataPower': 0, //母基金全数据权限1为是0为否 ,
                   'guestDataPower': 0, //客户全数据权限1为是0为否 ,======
                   'holdDataPower': 0, //持有中项目全数据权限1为是0为否 ,=====
                   'latentDataPower': 0, //潜在项目全数据权限1为是0为否（项目库） ,
                   'quasiDataPower': 0,//拟投资项目全数据权限1为是0为否 =====
                   'reserveDataPower': 0,//基金储备
                   'roleList': [],//所选角色 ,
                   'telephone': '',// 电话
                  // 'userEnable': 0 //停用启用状态1启用2禁用
               },
                rules: {
                  email: [
                      { required: true, message: '请输入邮箱地址', trigger: 'blur' },
                      { type: 'email', message: '请输入正确的邮箱地址', trigger: 'blur' }
                  ],
                  telephone: [
                      { validator: validatePass, trigger: 'blur',required: true },
                  ],
                  cnName: [
                      { required: true, message: '请输入用户名', trigger: 'blur' },
                  ],
                  deptId: [
                      { required: true, message: '请选择部门', trigger: 'change' },
                  ],
                }
            }
        },
        watch: {
        },
        beforeRouteEnter(to, from, next) {
            next(vm => {
                 vm.getUser();
                 vm.getDataAuth(true)
            });
        },
        mounted() {
            if (this.FOF) {
                this.authAllList = ['拟投资项目全数据权限','已投资项目全数据权限','拟设立基金全数据权限','已设立基金全数据权限','客户全数据权限','项目库全数据权限','投资中母基金','基金储备全数据权限']
            } else {
                this.authAllList = ['拟投资项目全数据权限','已投资项目全数据权限','拟设立基金全数据权限','已设立基金全数据权限','客户全数据权限','项目库全数据权限']
            }
        },
        methods: {
            //重置用户密码
            restUserPassword() {
                this.$confirm('是否要重置此用户密码?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    apiHttp(api.PUT_RESET_PWD, {'id': this.id}).then(ret => {
                        if (ret.resCode === STATUS_HTTP_SUCCESS) {
                            this.$message({
                                message: '密码重置成功!',
                                type: 'success',
                                center: true
                            });
                        }
                    })
                })
            },
            //点击tab
            handleClick() {
                this.getDataAuth()
            },
            //编辑时，删除tag标签时需要调借口-----需要注意
            deleteConnectRole(tag,checkedList) {//tagId为要关闭的角色的id
                if (this.id === '-1') {
                    this.$confirm('是否删除此角色?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }).then(() => {
                        this.currentRole = ''
                       checkedList.splice(checkedList.indexOf(tag), 1);
                    },() => {
//                        this.$message({
//                            type: 'info',
//                            message: '已取消删除',
//                            center: true
//                        });
                    })
                } else {
                    this.$confirm('是否删除此角色?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }).then(() => {
                        let params = {
                            userId: this.id,
                            roleId: tag.id,
                        }
                        api.DELETE_CONNET_ROLE.url = '/userEntity/users/deleteUserRole?userId=' + params.userId + '&roleId=' + params.roleId
                        apiHttp(api.DELETE_CONNET_ROLE, params).then(ret => {
                            if (ret.resCode === STATUS_HTTP_SUCCESS) {
                                this.currentRole = ''
                                this.$message({
                                    message: '删除关联角色成功!',
                                    type: 'success',
                                    center: true
                                });
                                checkedList.splice(checkedList.indexOf(tag), 1);
                                if (checkedList.length !== 0) {
                                    this.selectHandleClickRole(checkedList[0],0)
                                }
                            }
                        })
                    },() => {
//                        this.$message({
//                            type: 'info',
//                            message: '已取消删除',
//                            center: true
//                        });
                    })
                }
            },
            submitForm(formName) {
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                      this.addUser()
                    } else {
                        return false;
                    }
                });
            },
            selectHandleClickRole(tag,index) {
                //改变颜色
                for (let key in this.seclectRole) {
                    if (key === index.toString()) {
                        this.seclectRole[key].color = 'danger';
                    } else {
                        this.seclectRole[key].color = '';
                    }
                }
                //刷新dom
                this.seclectRole = this.seclectRole.filter(function (item) {
                    return item
                })
                this.callBack(tag.id,index)
            },
            callBack(id) {//id为当前tag的id  index为当前tag的index
                this.roleId = id //当前id
                this.getDataAuth(true)
            },
            //获取数据权限
            getDataAuth( flag ) {//flag是否改变当前的tab
                let params = {
                    id: this.id,
                    //id: '-1',
                    roleId: this.roleId,
                }
                if (params.id === '-1') {//新建用户时
                    params.id = ''
                    return;
                }
                if (params.roleId === '') {//新建用户时
                    this.allTabData = []
                    return;
                }
                apiHttp(api.GET_DATA_AUTH,params).then(ret=> {
                    if (ret.resCode === STATUS_HTTP_SUCCESS) {
                        this.allTabData = ret.data
                        //初始化数据
                        this.showTabArr = []
                        this.clientTabData = []
                        this.preInvestmentProjectTabData = []
                        this.establishedProjectTabData = []
                        this.preEstablishingFundsTabData = []
                        this.establishedFundsTabData = []
                        // 1拟投资项目,2已投资项目,3投资中母基金,4拟设立基金,5已设立基金,6客户,7潜在项目(项目库),8基金储备
                        // 直投： 母基金 、 基金储备 不显示权限
                        if (!this.FOF) {
                            this.allTabData.map((item,index)=> {
                                if (item.type === '3' || item.type === '8') { //type为7的不显示数据权限
                                    this.allTabData.splice(index, 1)
                                }
                            })
                        }
                        //数据赋值
                        this.allTabData.map((item)=> {
                            this.showTabArr.push(item.type)
                            //拟投资项目-- 权限数据
                            if (item.type === '1') {
                                item.name = '拟投资项目'
                                item.placeholder = '请选择行业'
                                item.header = '项目名称'
                                item.header2 = '所属行业'
                                item.title = '拟投资项目'
                                item.industryListAll = this.industryListAll
                                this.preInvestmentProjectTabData = this.dealTagShow( item.powerList,'1')
                            }
                            //已设立项目-- 权限数据
                            if (item.type === '2') {
                                item.name = '已投资项目'
                                item.placeholder = '请选择行业'
                                item.header = '项目名称'
                                item.header2 = '所属行业'
                                item.title = '已投资项目'
                                item.industryListAll = this.industryListAll
                                this.establishedProjectTabData = this.dealTagShow( item.powerList,'2')
                            }
                            //母基金-- 权限数据
                            if (item.type === '3') {
                                item.name = '投资中母基金'
                                item.placeholder = '请选择行业'//母基金不显示搜索框
                                item.header = '母基金名称'
                                item.header2 = '所属行业'//母基金不显示第二栏
                                item.title = '投资中母基金'
                                item.industryListAll = this.industryListAll
                                this.establishedProjectTabData = this.dealTagShow( item.powerList,'3')
                            }
                            //拟设立基金-- 权限数据
                            if (item.type === '4') {
                                item.name = '拟设立基金'
                                item.placeholder = '请选择行业'
                                item.header = '基金名称'
                                item.header2 = '所属行业'
                                item.title = '拟设立基金'
                                item.industryListAll = this.industryListAll
                                this.preEstablishingFundsTabData = this.dealTagShow( item.powerList,'4')
                            }
                            //已设立基金-- 权限数据
                            if (item.type === '5') {
                                item.name = '已设立基金'
                                item.placeholder = '请选择行业'
                                item.header = '基金名称'
                                item.header2 = '所属行业'
                                item.title = '已设立基金'
                                item.industryListAll = this.industryListAll
                                this.establishedFundsTabData = this.dealTagShow( item.powerList,'5')
                            }
                            //客户-- 权限数据
                            if (item.type === '6') {
                                item.name = '客户'
                                item.placeholder = '请选择客户类型'
                                item.header = '客户名称'
                                item.header2 = '客户类型'
                                item.title = '客户'
                                item.industryListAll = this.guestRelationship
                                this.clientTabData = this.dealTagShow( item.powerList,'6')
                            }
                            //项目库-- 权限数据
                            if (item.type === '7') {
                                item.name = '项目库'
                                item.placeholder = '请选择行业'
                                item.header = '项目名称'
                                item.header2 = '所属行业'
                                item.title = '项目'
                                item.industryListAll = this.industryListAll
                                this.establishedFundsTabData = this.dealTagShow( item.powerList,'7')
                            }
                            //8基金库-- 权限数据
                            if (item.type === '8') {
                                item.name = '基金储备'
                                item.placeholder = '请选择项目'//不显示
                                item.header = '基金名称'
                                item.header2 = '所属行业'//不显示
                                item.title = '基金'
                                item.industryListAll = this.industryListAll
                                this.establishedFundsTabData = this.dealTagShow( item.powerList,'8')
                            }
                        })
                        this.showTabArr = arrayUnique(this.showTabArr)
                        this.showTabArr.sort()
                        if (flag) {
                            this.activeName = this.showTabArr[0]
                        }
                    }
                })
            },
            //tab数据显示处理
            dealTagShow(dataArr,type) {
                let findArr = []
                if (type === '6') { //客户
                    findArr = this.guestRelationship
                } else { //其他
                    findArr = this.industryListAll
                }
                dataArr.map((item)=> {
                    if (item.checked === 1) {
                        item.checked = true
                    } else {
                        item.checked = false
                    }
                    item.industryIdArr = item.industryId.split(',')
                    item.industryIdShow = ''
                    item.industryIdArr.map((some)=>{
                        findArr.map((sub)=> { //找出对应id的name
                            if (some === sub.id) {
                                item.industryIdShow += sub.name + '、'
                            }
                        })
                    })
                })
                return dataArr;
            },
            //权限选择--全选
            handleCheckAllChange(val) {
                this.checkedAuth = val ? this.authAllList : [];
                this.isIndeterminate = false;
                if (val) { //点击全选
                    this.form.dataPower = 1
                    this.form.ansatDataPower = 1
                    this.form.estDataPower = 1
                    this.form.guestDataPower = 1
                    this.form.holdDataPower = 1
                    this.form.quasiDataPower = 1
                    this.form.latentDataPower = 1 // 项目库
                    if (this.FOF) {
                       this.form.fofDataPower = 1
                       this.form.reserveDataPower = 1 //基金储备
                    }
                } else {//再次点击
                    this.form.dataPower = 0
                    this.form.ansatDataPower = 0
                    this.form.estDataPower = 0
                    this.form.guestDataPower = 0
                    this.form.holdDataPower = 0
                    this.form.quasiDataPower = 0
                    this.form.latentDataPower = 0 // 项目库
                    if (this.FOF) {
                        this.form.fofDataPower = 0
                        this.form.reserveDataPower = 0 //基金储备
                    }
                }
            },
            //权限选择--子选项
            handleCheckedAuthChange(value) {
                let checkedCount = value.length;
                this.checkAuthAll = checkedCount === this.authAllList.length;
                this.isIndeterminate = checkedCount > 0 && checkedCount < this.authAllList.length;
                if (this.checkAuthAll) { //全选
                    this.form.dataPower = 1
                } else {
                    this.form.dataPower = 0
                }
                //子选项
                if (value.indexOf(this.authAllList[0]) !== -1) {
                    this.form.quasiDataPower = 1
                } else {
                    this.form.quasiDataPower = 0
                }
                if (value.indexOf(this.authAllList[1]) !== -1) {
                    this.form.holdDataPower = 1
                } else {
                    this.form.holdDataPower = 0
                }
                if (value.indexOf(this.authAllList[2]) !== -1) {
                    this.form.ansatDataPower = 1
                } else {
                    this.form.ansatDataPower = 0
                }
                if (value.indexOf(this.authAllList[3]) !== -1) {
                    this.form.estDataPower = 1
                } else {
                    this.form.estDataPower = 0
                }
                if (value.indexOf(this.authAllList[4]) !== -1 ) {
                    this.form.guestDataPower = 1
                } else {
                    this.form.guestDataPower = 0
                }
                if (value.indexOf(this.authAllList[5]) !== -1 ) { // 项目库
                    this.form.latentDataPower = 1
                } else {
                    this.form.latentDataPower = 0
                }
                if (this.FOF) {
                    if (value.indexOf(this.authAllList[6]) !== -1 ) { // 母基金
                        this.form.fofDataPower = 1
                    } else {
                        this.form.fofDataPower = 0
                    }
                    if (value.indexOf(this.authAllList[7]) !== -1 ) { //基金储备
                        this.form.reserveDataPower = 1
                    } else {
                        this.form.reserveDataPower = 0
                    }
                }
            },
            //添加用户 -or-编辑用户
            addUser() {
                if (this.flag) {
                    this.flag = false
                    let params = Object.assign({},this.form)
                    if (!this.FOF) {
                       delete params.fofDataPower
                       delete params.reserveDataPower
                    }
                    let arr = []
                    this.seclectRole.map((item)=>{
                        let obj = {
                            id: item.id,
                            name: item.name,
                        }
                        arr.push(obj)
                    })
                    params.roleList = arr //设置角色列表
                     let interfaceObj = {}
                     let message = ''
                     if (params.id === '') { //添加用户
                         interfaceObj = api.ADD_USER
                         message = '添加用户成功'
                     } else { //编辑用户
                         interfaceObj = api.Edit_USER
                         message = '修改用户成功'
                     }
                    apiHttp(interfaceObj,params).then(ret=> {
                        if (ret.resCode === STATUS_HTTP_SUCCESS) {
                            this.flag = true //等数据请求完，才能下一次请求
                            this.$message({
                                message: message,
                                type: 'success',
                                center: true,
                            })
                            this.$store.dispatch('refreshFieldList'); //更新字典
                            if (this.id === '-1') { //新建用户时跳转到编辑页
                                this.id = ret.data
                                this.form.id = this.id
                                //添加用户成功跳到编辑页
                                this.$router.push({ name: 'system-settings-user-add',params: {userId: this.id}})
                                this.getUser() //重新获取数据
                            } else {
                                this.cancel()
                            }
                        } else { //第一次提交电话时，电话占用，第二次提交时
                            this.flag = true //等数据请求完，才能下一次请求
                        }
                    })
                }
            },
            //获取用户信息
            getUser() {
                if (this.id === '-1') { //如果为新建，不调用接口
                    return;
                } else {//编辑
                    let params = {
                        id: this.id
                    }
                    apiHttp(api.GET_USER,params).then(ret=> {
                        if (ret.resCode === STATUS_HTTP_SUCCESS) {
                            let data = ret.data
                            this.form = {
                                'id': data.id, //用户id
                                'ansatDataPower': data.ansatDataPower, //拟设立基金全数据权限1为是0为否 ,=====
                                'cnName': data.cnName, //中文名 ,
                                'dataPower': data.dataPower,//项目基金数据权限 1为是0为否 ,=====
                                'deptId': data.deptId, //部门id
                                'email': data.email, //电子邮件
                                'enName': data.enName,//英文名
                                'estDataPower': data.estDataPower,//已设立基金全数据权限1为是0为否 ,====
                                'guestDataPower': data.guestDataPower, //客户全数据权限1为是0为否 ,======
                                'holdDataPower': data.holdDataPower, //持有中项目全数据权限1为是0为否 ,=====
                                'quasiDataPower': data.quasiDataPower,//拟投资项目全数据权限1为是0为否 =====
                                // 'fofDataPower': data.fofDataPower,//母基金
                                'latentDataPower': data.latentDataPower,// 项目库
                                // 'reserveDataPower': data.reserveDataPower,//基金储备
                                //'roleList': [],//角色 ,
                                'telephone': data.telephone,// 电话
                            }
                            if (this.FOF) {
                                this.form.fofDataPower = data.fofDataPower //母基金
                                this.form.reserveDataPower = data.reserveDataPower //基金储备
                            }
                            //处理显示角色
                            let arr = []
                            data.roleList.map((item)=> {
                                let obj = {
                                    id: item.id,
                                    name: item.roleName,
                                }
                                arr.push(obj)
                            })
                            this.seclectRole = arr  //当前的角色列表
                            //设置颜色 ，角色列表的第一个显示红色
                           if ( this.seclectRole.length > 0) {
                               this.seclectRole.map((tag,index)=> {
                                   if (index === 0) {
                                       tag.color = 'danger';
                                       this.roleId = arr[index].id  //设置当前角色id
                                       this.getDataAuth(true)
                                   } else {
                                       tag.color = '';
                                   }
                               })
                           }
                            if ( this.form.dataPower === 1) {//全选
                                this.checkedAuth = this.authAllList
                                this.checkAuthAll = true
                            } else {//非全选
                                //单个处理
                                if ( this.form.quasiDataPower === 1) {
                                    this.checkedAuth.push(this.authAllList[0])
                                }
                                if ( this.form.holdDataPower === 1) {
                                    this.checkedAuth.push(this.authAllList[1])
                                }
                                if ( this.form.ansatDataPower === 1) {
                                    this.checkedAuth.push(this.authAllList[2])
                                }
                                if ( this.form.estDataPower === 1) {
                                    this.checkedAuth.push(this.authAllList[3])
                                }
                                if ( this.form.guestDataPower === 1) {
                                    this.checkedAuth.push(this.authAllList[4])
                                }

                                if ( this.form.latentDataPower === 1) {
                                    this.checkedAuth.push(this.authAllList[5])
                                }
                                if (this.FOF) {
                                    if ( this.form.fofDataPower === 1) {
                                        this.checkedAuth.push(this.authAllList[6])
                                    }
                                    if ( this.form.reserveDataPower === 1) {
                                        this.checkedAuth.push(this.authAllList[7])
                                    }
                                }
                                if (this.checkedAuth.length > 0 && this.checkedAuth.length < this.authAllList.length) {
                                    this.isIndeterminate = true //checkbox 的不确定状态
                                }
                            }
                        }
                    })
                }
            },
            cancel() {
                this.$router.push({ name: 'system-settings-user-list',params: {roleId: '-1'}})
            }
        },
        components: {
            'csPreInvestmentProject': require('./preInvestmentProject2.vue'),//拟投资项目
//            'csPreInvestmentProject': require('./preInvestmentProject.vue'),//拟投资项目
//            'csEstablishedProject': require('./establishedProject.vue'),//已投资项目
//            'csPreEstablishingFunds': require('./preEstablishingFunds.vue'),//拟投资基金
//            'csEstablishedFunds': require('./establishedFunds.vue'),//拟投资项目
//            'csClient': require('./client.vue'),//拟投资项目
        },
    }
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
    //大格局的样式
.paddingRight{
    padding-right: 50px;
}
    .coverWidth{
        width:100%;
    }
//权限的样式
.authStyle{
    padding-left:23px;
    margin-bottom: 22px;
    .el-checkbox-group .el-checkbox:first-child{
        margin-left: 30px;
    }
}
//tag的样式
.tagStyle{
    line-height: 45px;
    .tagStyle-tag{
        margin-left:5px;
        cursor: pointer;
    }
}
.buttonStyle{
    padding: 50px 0 20px 0;
   text-align: center;
}
.el-checkbox-group .el-checkbox{
    line-height: 26px;
}
</style>
